/**
 * 
 */
package fr.cie.blog.controller;

import java.util.List;

import fr.cie.blog.beans.Category;
import fr.cie.blog.domainservice.IServiceCategory;

/**
 * @author Jee3
 * 
 */
public class CategoryAction extends GenericAction {

	/**
	 * serialVersionUID.
	 */
	private static final long serialVersionUID = 7555648802073790956L;

	/**
	 * category.
	 */
	private Category category;
	/**
	 * categoryList.
	 */
	private List<Category> categoryList;

	/**
	 * serviceCategory.
	 */
	private IServiceCategory serviceCategory;

	/**
	 * Constructor.
	 * 
	 * @param pServiceCategory
	 *            serviceCategory
	 */
	public CategoryAction(final IServiceCategory pServiceCategory) {
		super();
		serviceCategory = pServiceCategory;
	}

	/**
	 * @return the category
	 */
	public final Category getCategory() {
		return category;
	}

	/**
	 * @return the categoryList
	 */
	public final List<Category> getCategoryList() {
		return categoryList;
	}

	/**
	 * @return the serviceCategory
	 */
	public final IServiceCategory getServiceCategory() {
		return serviceCategory;
	}

	/**
	 * @param pCategory
	 *            the category to set
	 */
	public final void setCategory(final Category pCategory) {
		this.category = pCategory;
	}

	/**
	 * @param pcategoryList
	 *            the categoryList to set
	 */
	public final void setCategoryList(final List<Category> pcategoryList) {
		this.categoryList = pcategoryList;
	}

	/**
	 * @param pServiceCategory
	 *            the serviceCategory to set
	 */
	public final void setServiceCategory(
			final IServiceCategory pServiceCategory) {
		this.serviceCategory = pServiceCategory;
	}

	/**
	 * @return categoryList
	 */
	public final List<Category> showCategoryList() {
		categoryList = serviceCategory.findAll();
		return categoryList;
	}

	/**
	 * Add a new Category.
	 * 
	 * @return SUCCESS
	 */
	public final String addCategory() {
		serviceCategory.save(category);
		return SUCCESS;
	}
}
